import { createBrowserRouter } from 'react-router-dom';
import MainLayout from '../layout/mainLayout';
import ManageLayout from '../layout/manageLayout';
import QuestionLayout from '../layout/questionLayout';
import Home from '../pages/index/index';
import Login from '../pages/login/index';
import Register from '../pages/register/index';
import ManageList from '../pages/manage/list';
import ManageStar from '../pages/manage/star';
import ManageTrash from '../pages/manage/trash';
import QuestionEdit from '../pages/question/edit/index';
import QuestionStat from '../pages/question/stat/index';
import Notfound from '../pages/Notfound';

const router = createBrowserRouter([
  {
    path: '/',
    element: <MainLayout />,
    children: [
      {
        path: '/',
        element: <Home />,
      },
      {
        path: 'manage',
        element: <ManageLayout />,
        children: [
          {
            path: 'list',
            element: <ManageList />,
          },
          {
            path: 'star',
            element: <ManageStar />,
          },
          {
            path: 'trash',
            element: <ManageTrash />,
          },
        ]
      },
    ]
  },
  {
    path: '/login',
    element: <Login />,
  },
  {
    path: '/register',
    element: <Register />,
  },
  {
    path: '/question',
    element: <QuestionLayout />,
    children: [
      {
        path: 'edit/:id',
        element: <QuestionEdit />,
      },
      {
        path: 'stat/:id',
        element: <QuestionStat />,
      },
    ]
  },
  {
    path: '*',
    element: <Notfound />,
  },
]);

export default router;